package com.wxg.demo;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import com.wxg.utils.My;
import com.wxg.utils.MyDriver;

/**
 * http://www.w3school.com.cn/xpath/index.asp
 * -	* http://www.w3school.com.cn/xpath/xpath_functions.asp
 * http://www.ruanyifeng.com/blog/2009/07/xpath_path_expressions.html(阮一峰)
 * https://www.cnblogs.com/chenshaoping/p/5540434.html
 * -	* 这篇博客很符合我当下的需求
 * 
 * @author Wxg
 *
 */
public class WebDriverAndXpath {

	public static void main(String[] args) {
		code101();
	}
	
	/**
	 * xpath的使用,参考: https://www.cnblogs.com/chenshaoping/p/5540434.html
	 * 
	 * By.xpath("//*[starts-with(@id,'id_')]")
	 * 
	 */
	public static void code101(){
		String filepath = "D:\\wxg\\downloadStore\\20180206_2012001.html";
		WebDriver driver = MyDriver.getStaticDriver();
		driver.get(My.fileUrl(filepath));
		List<WebElement> list = driver.findElements(By.xpath("//*[starts-with(@id,'id_')]"));
		if(null != list){
			System.out.println( list.size() );
			for(WebElement ele : list){
				System.out.println( ele.getAttribute("outerHTML") );
				System.out.println();
			}
		}
		
		// webdriver quit
		MyDriver.closeStaticDriver();
	}
	
}
